﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2010-12-28 21:07:13Z</CreationDate>
</File>
*/
#endregion

using System;

using Outcoder.Services.MessageService;

namespace Outcoder.Services.Implementation
{
	public class MockMessageService : MessageServiceBase
	{
		public string Message { get; set; }
		public string Caption { get; set; }
		public MessageButton MessageButton { get; set; }
		public MessageImage MessageImage { get; set; }
		public MessageImportance? ImportanceThreshold { get; set; }
		public string Details { get; set; }
		
		MessageResult showCustomDialogResult = MessageResult.OK;

		public MessageResult ShowCustomDialogResult
		{
			get
			{
				return showCustomDialogResult;
			}
			set
			{
				showCustomDialogResult = value;
			}
		}

		public override MessageResult ShowCustomDialog(
			string message, 
			string caption, 
			MessageButton messageButton, 
			MessageImage messageImage, 
			MessageImportance? importanceThreshold, 
			string details)
		{
			Message = message;
			Caption = caption;
			MessageButton = messageButton;
			MessageImage = messageImage;
			ImportanceThreshold = importanceThreshold;
			Details = details;

			return showCustomDialogResult;
		}

		TextResponse askQuestionWithTextResponseResult 
			= new TextResponse(OkCancelQuestionResult.Ok, "MockMessageService response.");

		public TextResponse AskQuestionWithTextResponseResult
		{
			get
			{
				return askQuestionWithTextResponseResult;
			}
			set
			{
				askQuestionWithTextResponseResult = value;
			}
		}

		public object TextResponseQuestion { get; set; }
		public object MockResponseResult { get; set; }

#if SILVERLIGHT || MONODROID || MONOTOUCH
		public override void AskQuestion<TResponse>(
			IQuestion<TResponse> question, 
			Action<QuestionResult<TResponse>> resultHandler)
		{
			TextResponseQuestion = question;
			var questionResult = new QuestionResult<TResponse>(
				(TResponse)MockResponseResult, question);
			resultHandler(questionResult);
		}

#if WINDOWS_PHONE
		public override System.Threading.Tasks.Task<QuestionResult<TResponse>> AskQuestionAsync<TResponse>(
			IQuestion<TResponse> question)
		{
			throw new NotImplementedException();
		}
#endif
#else

		public TextResponse TextResponse { get; set; }

		public override TextResponse AskQuestionWithTextResponse(
			TextResponseQuestion textResponseQuestion)
		{
			TextResponseQuestion = textResponseQuestion;
			return TextResponse;
		}
#endif
	}
}
